<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('会员标签')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-label-link">
        <input type="hidden" name="memberId" th:value="${memberId}">
        <div class="form-group">
            <label class="col-sm-3 control-label">会员标签：</label>
            <div class="col-sm-6">
                <select id="labelId" class="form-control noselect2 selectpicker" data-none-selected-text="请选择会员标签" multiple>
                    <option th:each="one:${memberLabelList}" th:value="${one.id}" th:text="${one.labelName}" th:selected="${one.selected}"></option>
                </select>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js" />
<script type="text/javascript">
    var prefix = ctx + "back/shopMemberLabel";

    function submitHandler() {
        if ($.validate.form()) {
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + "/link",
                data: {
                    "memberId": $("input[name='memberId']").val(),
                    "labelIdArr": $.form.selectSelects("labelId"),
                },
                async: false,
                error: function (request) {
                    $.modal.alertError("系统错误");
                },
                success: function (data) {
                    $.operate.successCallback(data);
                }
            });
        }
    }
</script>
</body>
</html>